package com.wg.wuge.controller;

import com.wg.wuge.dto.*;
import com.wg.wuge.service.SongService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@RestController
public class PersonalizedController {

    @Resource
    SongService songService;

    @RequestMapping(method = RequestMethod.GET, value = "/personalized")
    public ResulT<List<RecommendSongList>> personalized(@RequestParam(value = "limit", required = false) Integer limit) {
        List<RecommendSongList> list = songService.personalized(limit);
        return ResulT.success(list);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/personalized/newsong")
    public ResulT<List<NewSongDto>> newsong() {
        NewSongDto detail = new NewSongDto();
        SongDto songDto = new SongDto();
        songDto.setId("123");
        songDto.setDuration(123);
        detail.setSong(songDto);
        detail.setName("123");
        detail.setPicUrl("http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg");
        ArtistDto artistDto = new ArtistDto();
        artistDto.setId("123");
        artistDto.setName("123");
        songDto.setArtists(Arrays.asList(artistDto));
        return ResulT.success(Arrays.asList(detail));
    }

    @RequestMapping(method = RequestMethod.GET, value = "/personalized/mv")
    public ResulT<List<NewSongDto>> mv() {
        NewSongDto songDto = new NewSongDto();
        songDto.setPlayCount(10);
        return ResulT.success(Arrays.asList(songDto));
    }


    @RequestMapping(method = RequestMethod.GET, value = "/song/url")
    public ResulTData<List<SongUrlDto>> songUrl(@RequestParam(value = "id", required = false) String id) {
        SongUrlDto songDto = new SongUrlDto();
        songDto.setName("123");
        songDto.setAr("123");
        songDto.setDt(123);
        songDto.setId(1);
        SongUrlAlDto al = new SongUrlAlDto();
        al.setId(2);
        al.setName("1231");
        al.setPicUrl("http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg");
        songDto.setAl(al);
        songDto.setImageUrl("http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg");
        songDto.setUrl("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4");
        return ResulTData.success(Arrays.asList(songDto));
    }

    @RequestMapping(method = RequestMethod.GET, value = "/lyric")
    public ResulTData<List<SongUrlDto>> lyric(@RequestParam(value = "id", required = false) String id) {
        SongUrlDto songDto = new SongUrlDto();
        songDto.setUrl("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4");
        return ResulTData.success(Arrays.asList(songDto));
    }

    @RequestMapping(method = RequestMethod.GET, value = "/banner")
    public ResulTData<BannerDto> banner() {
        SongUrlDto songDto = new SongUrlDto();
        songDto.setImageUrl("http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg");
        BannerDto result = new BannerDto();
        result.setBanners(Arrays.asList(songDto));
        return ResulTData.success(result);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/playlist/detail")
    public ResulTData<PlayListDto> playListDetail(@RequestParam(value = "id", required = false) Integer id) {
        PlayListDto playListDto = songService.playListDetail(id);
        return ResulTData.success(playListDto);
    }


    @RequestMapping(method = RequestMethod.GET, value = "/song/detail")
    public ResulTData<SongDetailDto> songDetail(@RequestParam(value = "ids", required = false) Integer ids) {
        SongDetailDto songDetailDto = songService.songDetail(ids);
        return ResulTData.success(songDetailDto);

    }

    @RequestMapping(method = RequestMethod.GET, value = "/comment/{type}")
    public ResulTData<CommentDto> comment(@PathVariable String type) {
        CommentDto result = new CommentDto();
        CommentDetailDto detailDto = new CommentDetailDto();
        detailDto.setTime(new Date());
        result.setComments(Arrays.asList(detailDto));
        result.setHotComments(new ArrayList<>());
        return ResulTData.success(result);
    }
}
